#
rm(list=ls())
load("Eisner/d541.RData")

## load allpathway
load("Eisner/allpathway541.RData")

library(ctgt)
library(tictoc)

y = d541[,ncol(d541)]
X = d541[,-ncol(d541)]
xs = colnames(X)

IT = seq(0,20000, 1000)
res_unsure = rep(0, length(IT) )
res_reject = rep(0, length(IT) )
res_notreject = rep(0, length(IT) )

for(i in 1:length(IT) ){
  print(i)
  tic("time")
  resctgt = sapply(allpathway541, function(u) actgt(y,X,xs, as.character(u),maxit= IT[i])[1])
  toc()
  res_unsure[i] =  sum(resctgt=="unsure" ) 
  res_reject[i] =  sum(resctgt=="reject" ) 
  res_notreject[i] =  sum(resctgt=="not reject" ) 
  if(sum(resctgt=="unsure" ) ==0) break  
}

res_unsure
res_reject
res_notreject


######################################  RESULTS OBTAINED ###########################################
its = seq(0,20000,1000)[1:18]
##      0  1000  2000  3000  4000  5000  6000  7000  8000  9000 10000 11000 12000 13000 14000 15000 16000 17000

res_unsure = res_unsure[1:18]
## 58 29 16 15 13 11 10  8  5  4  4  2  2  2  1  1  1  0

res_reject = res_reject[1:18]
## 529 558 571 571 573 575 576 578 581 582 582 584 584 584 585 585 585 586

res_notreject = res_notreject[1:18]
## 173 173 173 174 174 174 174 174 174 174 174 174 174 174 174 174 174 174

secs =  c(49.303,4206.102 ,5984.909,6800.012,8434.031,9698.418,11300.643,14855.919 ,15665.076 ,
          17296.328 ,19083.869 ,20243.557 ,20689.829 ,21404.269 ,22722.634 ,22221.32 ,22586.704,21497.363)




